package com.ssy.lingxi.member.merchant.entity;

import com.fasterxml.jackson.annotation.JsonBackReference;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 会员信用信息
 * @author 万宁
 * @version 2.0.0
 * @date 2020-07-16
 */
@Entity
@Table(schema = "public", name = "ms_mc_member_credit", indexes = {@Index(name="ms_mc_member_credit_member_role_id_idx", columnList = "memberId,roleId"), @Index(name="ms_mc_member_credit_sub_member_role_id_idx", columnList = "subMemberId,subRoleId"), @Index(name="ms_mc_member_credit_rel_id_idx", columnList = "rel_id")})
public class MemberCreditDO implements Serializable {
    private static final long serialVersionUID = -2005255836112874403L;

    @Id
    @GeneratedValue(strategy= GenerationType.SEQUENCE, generator="member_credit_seq")
    @SequenceGenerator(sequenceName="ms_mc_member_credit_seq", name="member_credit_seq",allocationSize = 1)
    private Long id;

    /**
     * 上级会员Id
     */
    @Column
    private Long memberId;

    /**
     * 上级会员角色Id
     */
    @Column
    private Long roleId;

    /**
     * 下级会员Id
     */
    @Column
    private Long subMemberId;

    /**
     * 下级会员角色Id
     */
    @Column
    private Long subRoleId;

    /**
     * 一对一双向关联会员关系表
     */
    @JsonBackReference
    @OneToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
    @JoinColumn(name="rel_id", referencedColumnName="id", foreignKey = @ForeignKey(name = "none",value = ConstraintMode.NO_CONSTRAINT))
    private MemberRelationDO relation;

    /**
     * 信用积分 = 交易评价积分 + 售后评价积分 + 投诉扣分 + 入驻年数积分
     */
    @Column(columnDefinition = "int")
    private Integer creditPoint;

    /**
     * 交易评价积分
     */
    @Column(columnDefinition = "int")
    private Integer tradeCommentPoint;

    /**
     * 售后评价积分
     */
    @Column(columnDefinition = "int")
    private Integer afterSaleCommentPoint;

    /**
     * 投诉扣分
     */
    @Column(columnDefinition = "int")
    private Integer complainPoint;

    /**
     * 入驻年数积分
     */
    @Column(columnDefinition = "int")
    private Integer registerYearsPoint;

    /**
     * 入驻年数积分更新时间
     */
    @Column(columnDefinition = "timestamp")
    private LocalDateTime registerPointUpdateTime;

    /**
     * 交易评价平均星级（总体满意度）
     */
    @Column(columnDefinition = "int")
    private Integer avgTradeCommentStar;

    /**
     * 交易评价总次数
     */
    @Column(columnDefinition = "int")
    private Integer tradeCommentCount;

    /**
     * 交易评价总星级
     */
    @Column(columnDefinition = "int")
    private Integer tradeCommentStars;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getMemberId() {
        return memberId;
    }

    public void setMemberId(Long memberId) {
        this.memberId = memberId;
    }

    public Long getRoleId() {
        return roleId;
    }

    public void setRoleId(Long roleId) {
        this.roleId = roleId;
    }

    public Long getSubMemberId() {
        return subMemberId;
    }

    public void setSubMemberId(Long subMemberId) {
        this.subMemberId = subMemberId;
    }

    public Long getSubRoleId() {
        return subRoleId;
    }

    public void setSubRoleId(Long subRoleId) {
        this.subRoleId = subRoleId;
    }

    public MemberRelationDO getRelation() {
        return relation;
    }

    public void setRelation(MemberRelationDO relation) {
        this.relation = relation;
    }

    public Integer getCreditPoint() {
        return creditPoint;
    }

    public void setCreditPoint(Integer creditPoint) {
        this.creditPoint = creditPoint;
    }

    public Integer getTradeCommentPoint() {
        return tradeCommentPoint;
    }

    public void setTradeCommentPoint(Integer tradeCommentPoint) {
        this.tradeCommentPoint = tradeCommentPoint;
    }

    public Integer getAfterSaleCommentPoint() {
        return afterSaleCommentPoint;
    }

    public void setAfterSaleCommentPoint(Integer afterSaleCommentPoint) {
        this.afterSaleCommentPoint = afterSaleCommentPoint;
    }

    public Integer getComplainPoint() {
        return complainPoint;
    }

    public void setComplainPoint(Integer complainPoint) {
        this.complainPoint = complainPoint;
    }

    public Integer getRegisterYearsPoint() {
        return registerYearsPoint;
    }

    public void setRegisterYearsPoint(Integer registerYearsPoint) {
        this.registerYearsPoint = registerYearsPoint;
    }

    public LocalDateTime getRegisterPointUpdateTime() {
        return registerPointUpdateTime;
    }

    public void setRegisterPointUpdateTime(LocalDateTime registerPointUpdateTime) {
        this.registerPointUpdateTime = registerPointUpdateTime;
    }

    public Integer getAvgTradeCommentStar() {
        return avgTradeCommentStar;
    }

    public void setAvgTradeCommentStar(Integer avgTradeCommentStar) {
        this.avgTradeCommentStar = avgTradeCommentStar;
    }

    public Integer getTradeCommentCount() {
        return tradeCommentCount;
    }

    public void setTradeCommentCount(Integer tradeCommentCount) {
        this.tradeCommentCount = tradeCommentCount;
    }

    public Integer getTradeCommentStars() {
        return tradeCommentStars;
    }

    public void setTradeCommentStars(Integer tradeCommentStars) {
        this.tradeCommentStars = tradeCommentStars;
    }
}
